<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="public/css/index.css" />
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  </head>

  <body>
    <div class="outer">
      <div class="con">
        <img src="public/img/logo.png" alt="" />
        <h2 id="welCome">欢迎光临 888号为您服务</h2>
      </div>
    </div>
    <script>
      const oWelCome = document.getElementById("welCome");
      axios.interceptors.response.use(
        (response) => {
          // Do something before response is sent
          if (response.data.code === 100000) {
            return response.data.msg;
          } else {
            return Promise.reject(response.data.msg);
          }
        },
        (error) => {
          // Do something with response error
          return Promise.reject(error);
        }
      );
      axios
        .post("/center")
        .then((res) => {
          oWelCome.innerHTML = `欢迎光临${res} 888号为您服务`;
          console.log(res);
        })
        .catch((err) => {
          location.href = "./index.html";
          alert(err);
        });
    </script>
  </body>
</html>
